# Contributor: kedap <kedap.dev@protonmail.com>
# Maintainer: kedap <kedap.dev@protonmail.com>
pkgname=apmpkg
pkgver=1.5.1
pkgrel=0
pkgdesc="A Package Manager as a model: PKGBUILD"
url="https://github.com/kedap/apmpkg"
# armhf: test timeout
# s390x, riscv64: limited by rust/cargo
arch="all !s390x !armhf !riscv64"
license="Apache-2.0"
depends="git fakeroot wget ruby-bundler py3-pip bash ruby-dev npm"
makedepends="cargo openssl-dev patchutils"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/Kedap/apmpkg/archive/refs/tags/$pkgver.tar.gz
	fix-with-outdated-rust.patch
	"

build() {
	cargo build --release --locked --verbose
}

check() {
	cargo test --all --release --locked --verbose
}

package() {
	install -Dm 755 target/release/$pkgname -t "$pkgdir"/usr/bin
	mkdir -p "$pkgdir"/etc/apmpkg
	cp -r src/iiabc "$pkgdir"/etc/apmpkg
	mkdir -p $pkgdir/etc/apmpkg/paquetes

	#Install documentation
	install -Dm0644 man/*.1 -t "$pkgdir"/usr/share/man/man1

	#Install bash completion
	install -Dm0644 completions/$pkgname.bash-completion \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname

	#Install zsh completion
	install -Dm0644 completions/_$pkgname \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname

	#Install fish completion
	install -Dm0644 completions/$pkgname.fish \
		"$pkgdir"/usr/share/fish/completions/$pkgname.fish
}

sha512sums="
20190348ab2a2d12b2647dcdd017e6fb739b3cf2c3eb559b15d0ce7058d38fd9bccd3bc4385707594e0bebb551d746df6a646f94d079d5b92f7a8c366a350c61  apmpkg-1.5.1.tar.gz
31c7b35f4bd114d3ccae4bffe5e0bcdb4a477f1803206ba771dcfc212a03df741387abbd110a407e6f057aedfa620c694898875b9be52388fced8aa360a09fef  fix-with-outdated-rust.patch
"
